<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('操作记录')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "system/mMailWF";

    $(function () {
        var options = {
            url: prefix + "/forShow/logListJson/"+[[${wfId}]],
            detailUrl: prefix + "/forShow/logDetail/{id}",
            sortName: "myPkVal",
            sortOrder: "desc",
            uniqueId: "myPkVal",
            modalName: "操作记录",
            columns: [
                {field: 'myPkVal', title: '流水号', hidden: true,visible:false},
                {field: 'SpareString', title: '信件来源', align: 'center', halign: 'center', sortable: true},
                {field: 'WfId', title: 'WfId', hidden: true,visible:false},
                {field: 'opTime', title: '操作时间', align: 'center'},
                {field: 'OpDeptName', title: '单位名称', align: 'center', halign: 'center', sortable: true},
                {field: 'OpUserName', title: '操作人', align: 'center', sortable: true},
                {field: 'OpAction', title: '动作', align: 'center'},
                {field: 'OpDesc', title: '操作简述', align: 'center', halign: 'center',
                    formatter:function (value, row, index){
                        return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle:cellEllipsis
                },
                {
                    field: 'WsOpen',
                    title: '公开',
                    align: 'center',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return fmtWFormOpen(value, row, index);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.myPkVal + '\')"><i class="fa fa-edit"></i>详情</a> ');
                        actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="updateOpen(\'' + row.myPkVal + '\')"><i class="fa fa-remove"></i>切换公开</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    //切换公开状态
    function updateOpen(pkValue){
        $.ajax({
            type: "post",
            url: prefix+"/forShow/updateState/" + pkValue,
            success: function(){
                $.modal.msgSuccess("切换成功");
                $.table.refresh();
            }
        });
    }
</script>
</body>
</html>